<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 

class Date extends codexForms
{
    function Date($name,$params) { 
        codexForms::initiate($name,$params);
    }

    function prepForDisplay($value){
        if(!empty($value) AND ($value != 0 AND $value != "0000-00-00")){
            $explode = explode('-',$value);
            return date('F j, Y',mktime(0,0,0,$explode[1],$explode[2],$explode[0]));
        } 
        else
            return '';
    }

	function getHTML()
	{
        $CI = &get_instance();
        $CI->codextemplates->css('css-datepicker','ui.datepicker.css');
        $CI->codextemplates->js('js-datepicker','ui.datepicker.js');

        $html = $this->prefix;
        $html .= $this->getMessage($this->name);
        $html .= '
            <label for="'.$this->name.'">
                '.$this->label.'
            </label>';
        $html .='
            <input class="text" type="text" id="'.$this->name.'_picker" value="'.$this->value.'" name="'.$this->name.'" '.$this->getAttributes($this->attributes).'>
        ';
        $html .='<script type="text/javascript">$(document).ready(function() {$(\'#'.addcslashes($this->name,'[]').'_picker\').datepicker({dateFormat: \'yy-mm-dd\'}); });</script>';

		$html .= $this->suffix;
		
		return $html;
	}
}

?>
